home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tcl7.4 / compat / tmpnam.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-18  |  1002 b   |  40 lines

  1. /*
  2.  * Copyright (c) 1988 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that this notice is preserved and that due credit is given
  7.  * to the University of California at Berkeley. The name of the University
  8.  * may not be used to endorse or promote products derived from this
  9.  * software without specific written prior permission. This software
  10.  * is provided ``as is'' without express or implied warranty.
  11.  */
  12.  
  13. static char sccsid[] = "@(#) tmpnam.c 1.1 94/08/09 13:17:13";
  14.  
  15. #include <sys/param.h>
  16. #include <sys/stat.h>
  17. #include <sys/file.h>
  18. #include <stdio.h>
  19.  
  20. /*
  21.  * Use /tmp instead of /usr/tmp, because L_tmpname is only 14 chars
  22.  * on some machines (like NeXT machines) and /usr/tmp will cause
  23.  * buffer overflows.
  24.  */
  25.  
  26. #define    P_tmpdir    "/tmp"
  27.  
  28. char *
  29. tmpnam(s)
  30.     char *s;
  31. {
  32.     static char name[50];
  33.     char *mktemp();
  34.  
  35.     if (!s)
  36.         s = name;
  37.     (void)sprintf(s, "%s/XXXXXX", P_tmpdir);
  38.     return(mktemp(s));
  39. }
  40.